var _linker = {
  attach: function() {
    //Config
    var enableCrosslink = true; // Rollup reporting - pending switch
    var enableFormtrack = false; // Form tracking - pending
   // loop through all anchors
   $('a').each(function() {
      var linkurl = $(this).attr('href');
      var isLocal = /^(?!http|mailto)/.test(linkurl);
      var isThisDomain = /www\.sample\.com/.test(linkurl);
      var isFile = /(\.pdf|\.doc|\.xls|\.ppt)/.test(linkurl);
      if(isFile){
        url = linkurl;
        url = url.substr(url.lastIndexOf('/')+1, url.length);
        var extension =(url.substring(url.lastIndexOf("\.")+1));
      }
      if (isLocal || isThisDomain) {
        if (isFile) {
          $(this).click(function(){_gaq.push(['main._trackEvent', extension, 'Download' , linkurl]);});
        } else {}
      }
      else{
        var isOwnDomain = /(sample1\.com|sample2\.com)/.test(linkurl);
        if(isOwnDomain) {
          if(isFile) $(this).click(function(){_gaq.push(['main._trackEvent', extension, 'Download' , linkurl]);});
          else {
            $(this).click(function(){
              _gaq.push(['main._trackEvent', 'External Link', 'Inbound' , linkurl]); 
              function linkwrap(rollurl){ 
                if(_gat) window.open(_gat._getTrackerByName("rollup")._getLinkerUrl(rollurl));
              }
              linkwrap(linkurl);
              return false;
            });
          }
        }
        else {
          if(isFile) $(this).click(function(){_gaq.push(['main._trackEvent', extension, 'Download' , linkurl]);});
          else $(this).click(function(){_gaq.push(['main._trackEvent', 'External Link', 'Outbound' , linkurl]);});
        }
      }
    });
  }
}
try {
  (jQuery)(function ($) {
    _linker.attach();
  })
}catch (err) {}